#include <iostream>
#include <string.h>
#include <fstream>
#include <vector>
#include <pthread.h>
#include <stdlib.h>//srand(),rand()
#include <sys/time.h>


using namespace std;

const long N = 10000000000;

int main ()
{
	volatile char buf[16] = {'\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0'};
	//char* buf = new char[16];
	memset ((void*)buf, '\0', 16);
	timeval starttime,endtime;
	long int timeuse;
	int x;
	/*
	gettimeofday(&starttime,0);
	
	volatile int* pa = (int*)(buf+3);
	printf("%p\n", pa);
	for ( long i = 0; i < N; i++ )
	{
		x = *pa;
		x = *pa;
		x = *pa;
		x = *pa;
		x = *pa;
		x = *pa;
		x = *pa;
		x = *pa;
		x = *pa;
		x = *pa;
	}
	//cout << *pa << endl;

	gettimeofday(&endtime,0);
	timeuse = 1000000*(endtime.tv_sec - starttime.tv_sec) + endtime.tv_usec - starttime.tv_usec;
	cout << timeuse << " us" << endl;
	//*/
	
	///*
	gettimeofday(&starttime,0);
	
	volatile int* pb = (int*)(buf+7);
	printf("%p\n", pb);
	for ( long i = 0; i < N; i++ )
	{
		x = *pb;
		x = *pb;
		x = *pb;
		x = *pb;
		x = *pb;
		x = *pb;
		x = *pb;
		x = *pb;
		x = *pb;
		x = *pb;
	}
	//cout << *pb << endl;

	gettimeofday(&endtime,0);
	timeuse = 1000000*(endtime.tv_sec - starttime.tv_sec) + endtime.tv_usec - starttime.tv_usec;
	cout << timeuse << " us" << endl;
	//*/
	//delete [] buf;
	return 0;
}

